package user

import (
	cs_message "sanguo/protocol/cs/message"
	"time"

	"github.com/sniperHW/kendynet"
)

func (this *User) kickByLogin(session kendynet.StreamSession) {
	if session == this.session {
		return
	}
	this.kick()
}

func (this *User) kick() {
	if this.checkStatus(status_playing) || this.checkStatus(status_reconnect) {
		this.setStatus(status_kick)
		//第一步清空待处理的trans
		this.transMgr.Clear()

		if nil != this.session {
			this.Post(&cs_message.KickToC{})
			this.session.Close("kick", time.Second)
		}
		this.doFinalSave()
	}
}
